package com.example.demo.controller;

import com.example.demo.entity.ResponseInfo;
import com.example.demo.entity.request.uiTestCaseSuiteReq.UITestCaseSuiteAddReq;
import com.example.demo.entity.request.uiTestCaseSuiteReq.UITestCaseSuiteEditReq;
import com.example.demo.entity.vo.uiTestCaseSuiteVO.UITestCaseSuiteDetailVO;
import com.example.demo.service.UITestCaseSuiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Validated
@RequestMapping("/UITestSuite")
@Api(value = "/UITestSuite", tags = "ui测试用例分类接口")
public class UITestCaseSuiteController {

    @Resource
    UITestCaseSuiteService uiTestCaseSuiteService;

    @PostMapping("/add")
    @ApiOperation(value = "ui测试用例分类新增接口")
    public ResponseInfo<String> add(@RequestBody UITestCaseSuiteAddReq req) {
        req.validate();
        uiTestCaseSuiteService.add(req);
        return ResponseInfo.successInfo("");
    }

    @PostMapping("/update")
    @ApiOperation(value = "ui测试用例分类更新接口")
    public ResponseInfo<String> update(@RequestBody UITestCaseSuiteEditReq req) {
        req.validate();
        uiTestCaseSuiteService.update(req);
        return ResponseInfo.successInfo("");
    }

    @GetMapping("/detail")
    @ApiOperation(value = "ui测试用例分类详情接口")
    public ResponseInfo<UITestCaseSuiteDetailVO> detail(@RequestParam Long id) {
        return ResponseInfo.successInfo(uiTestCaseSuiteService.detail(id));
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "ui测试用例分类删除接口")
    public ResponseInfo<String> delete(@PathVariable(value = "id") Long id) {
        uiTestCaseSuiteService.delete(id);
        return ResponseInfo.successInfo("");
    }
}
